#!/usr/bin/env python
import sys
import os

#--------clear exist cmake generated files----------------------------

#os.system("find . -name 'Makefile' -o -name '.project'  -o -name '.cproject' -o -name 'cmake_install.cmake' -o -name 'CMakeCache.txt' -o -name 'CMakeFiles' > hicmake")
#f = open("hicmake",'r')
#for item in f:
#    print(item)
#    os.system("rm -rf "+item)

#makeProgram  = "-DCMAKE_MAKE_PROGRAM:FILEPATH=C:\\MinGW\\msys\\1.0\\bin\\make.exe "
#generator = '-G "Eclipse CDT4 - Unix Makefiles" '
#generator = '-G "Unix Makefiles" '

makeProgram  = "-DCMAKE_MAKE_PROGRAM:FILEPATH=C:\\MinGW\\bin\\mingw32-make "
generator = '-G "Eclipse CDT4 - MinGW Makefiles" '
#generator = '-G "MinGW Makefiles" '
if os.path.exists("/bin/sh.exe"):
    os.system("cp /bin/sh.exe /bin/sh_back.exe")
    os.system("rm -f /bin/sh.exe")



if os.path.exists("/bin/sh_back.exe"):
    os.system("cp /bin/sh_back.exe /bin/sh.exe")
    os.system("rm -f /bin/sh_back.exe ")

c_compiler = "-DCMAKE_C_COMPILER=clang "
cxx_compiler = "-DCMAKE_CXX_COMPILER=clang++ "
#c_compiler = "-DCMAKE_C_COMPILER=gcc "
#cxx_compiler = "-DCMAKE_CXX_COMPILER=g++ "
buildtype = "-DCMAKE_BUILD_TYPE=Debug "
os.system("cmake " \
        + generator \
        + c_compiler \
        + cxx_compiler \
        + buildtype \
        + makeProgram \
        + "../.." ) #toppest CMakeList.txt
